#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<math.h>

int Is_prime(int x)
{
    int i = 0;
    for (i = 2; i <= sqrt(x); i++)
    {
        if (x % i == 0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int M = 0;
    int N = 0;
    scanf("%d %d", &M, &N);
    int i = 2;
    int count1 = 0;
    int count2 = 0;
    while (1)
    {
        if (Is_prime(i))
        {
            count1++;
            if (count1 >= M)
            {
                printf("%d", i);
                count2++;
                if (count1 == N)
                {
                    break;
                }
                if (10 == count2)
                {
                    printf("\n");
                    count2 = 0;
                }
                else
                {
                    printf(" ");
                }
            }
        }
        i++;
    }
    return 0;
}
#include<stdio.h>

void Print(int sum, int x)
{
    if (sum < x)
    {
        printf("%d", sum);
    }
    else
    {
        Print(sum / x, x);
        printf("%d", sum % x);
    }
}

int main()
{
    int A, B, D;
    scanf("%d %d %d", &A, &B, &D);
    int sum = A + B;
    Print(sum, D);
    return 0;
}